package cn.z2huo.knowledge.reference;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 *
 * @author  z2huo
 */
public class Test {

    public static void main(String[] args) {

        String string = "hello";
        String string2 = testString(string);
        System.out.println(string);
        System.out.println(string2);
        System.out.println(string == string2);

        System.out.println();
        int i = 1;
        int j = testInt(i);
        System.out.println(i);
        System.out.println(j);
        System.out.println(i == j);

        System.out.println();
        List<String> list = new ArrayList<>(List.of("hhh", "www"));
        List<String> list2 = testList(list);
        System.out.println(list);
        System.out.println(list2);
        System.out.println(list == list2);

        System.out.println();
        List<String> list3 = new ArrayList<>(List.of("hhh", "www"));
        List<String> list4 = testList2(list3);
        System.out.println(list3);
        System.out.println(list4);

        System.out.println();
        List<String> list5 = new ArrayList<>(List.of("hhh", "www"));
        List<String> list6 = list5;
        List<String> list7 = list5;
        System.out.println(list5);
        System.out.println(list6);
        System.out.println(list7);

        list6 = List.of("11", "22");
        list7 = List.of("33", "44");
        System.out.println(list5);
        System.out.println(list6);
        System.out.println(list7);
    }

    public static List<String> testList2(List<String> list) {
        return list;
    }

    public static List<String> testList(List<String> list2) {
        list2.add("aaa");
        list2 = new ArrayList<>(List.of("111", "222"));
        return list2;
    }

    public static String testString(String string) {
        string = "world";
        return string;
    }

    public static int testInt(int i) {
        i = 1000;
        return i;
    }
}
